//
//  CYEmoticonCell.m
//  LingLingBang
//
//  Created by 郝俊聪 on 15/12/28.
//  Copyright © 2015年 zhaohongling. All rights reserved.
//

#import "CYEmoticonCell.h"
#import "CYEmoticon.h"

@interface CYEmoticonCell()

@property (nonatomic, strong) UIButton *imageButton;

@end

@implementation CYEmoticonCell

//重写set方法，设置按钮数据
- (void)setEmoticon:(CYEmoticon *)emoticon
{
    _emoticon = emoticon;
    
    //是删除按钮
    if (emoticon.isDelete) {
        [self.imageButton setTitle:@"删" forState:UIControlStateNormal];
        [self.imageButton setImage:[UIImage imageNamed:@"emoticon_delete"] forState:UIControlStateNormal];
        return;
    }
    //是空按钮
    if (emoticon.isEmpty) {
        [self.imageButton setTitle:@"空" forState:UIControlStateNormal];
        self.imageButton.titleLabel.textColor = [UIColor blackColor];
        [self.imageButton setImage:nil forState:UIControlStateNormal];
        return;
    }
    //是图片按钮
    if (emoticon.png) {
        [self.imageButton setTitle:@"" forState:UIControlStateNormal];
        [self.imageButton setImage:[UIImage imageNamed:emoticon.png] forState:UIControlStateNormal];
    }
}

#pragma mark - 懒加载
- (UIButton *)imageButton
{
    if (!_imageButton) {
        _imageButton = [[UIButton alloc] initWithFrame:CGRectInset(self.bounds, 2, 2)];
        _imageButton.titleLabel.font = SYSTEMFONT(15);
        _imageButton.userInteractionEnabled = NO;
        [self.contentView addSubview:_imageButton];
    }
    return _imageButton;
}

@end
